from django.shortcuts import render
from django.http import HttpResponse, Http404, JsonResponse
# Create your views here.
import json

def error(request, *args, **kwargs):
    status_code = kwargs['status']
    print(status_code)
    if int(status_code) < 1000:
        #return Http404("Poll does not exist")
        return HttpResponse(status = status_code)
    return render(request, 'app3/index.html', {
        'view_name': 'error :' + str(status_code)
    })

def urljson(request):
    dic = {"name": "qiaoansheng乔安生", "age": 18, "url": "urljson"};
    return HttpResponse(json.dumps(dic,ensure_ascii = False),
                        content_type = "application/json,charset=utf-8")

def urljson1(request):
    dic = {"name": "qiaoansheng乔安生", "age": 18, "url": "urljson1"};
    return JsonResponse(dic)

def index(request):
    return render(request, 'app3/index.html', {
        'view_name': 'index'
    })

